﻿//机床信息
function loadTreeData(firstLoad) 
{

    var deptid =document.getElementById("selectdeptID").value;
    var machineName = document.getElementById("machineName").value;
    var strMachineid="'";
    var mdt = new Ajax.Web.DataTable();


                   mdt = Index.GetMachine(deptid,machineName);//added by zhaolei
                    if (mdt.value != null && mdt.value.Rows.length > 0)
                      {
                        for (var j = 0; j < mdt.value.Rows.length; j++)
                         {
                            if (mdt.value.Rows[j].MATOLNAME != null && mdt.value.Rows[j].MATOLNAME.toString != ""
                            && mdt.value.Rows[j].MATOLID != null && mdt.value.Rows[j].MATOLID.toString != "") 
                            {
                                strMachineid =strMachineid+mdt.value.Rows[j].INTID+",";
                            }
                          }
                       }
                       document.getElementById("selectedMachineID").value = strMachineid+"'";
}
//任务信息
function loadTreeData1(firstLoad) {
    var strDeptid="'";
    var deptid =document.getElementById("selectdeptID").value;
    var procedureNum = document.getElementById("procedureNum").value;
    var partDrawing = document.getElementById("partDrawing").value;
   

    var mdt2 = new Ajax.Web.DataTable();
    mdt2 = Index.GetTaskInfo(deptid,"", 3,procedureNum,partDrawing);
    if (mdt2.value != null && mdt2.value.Rows.length > 0)
     {

        for (var k = 0; k < mdt2.value.Rows.length; k++)
         {
            strDeptid =strDeptid+mdt2.value.Rows[k].BOMPARTSONID+",";
         }

     }
     document.getElementById("selectedProcedureID").value = strDeptid+"'";
    }




var treeMachine3;
function loadTreeData3(firstLoad) {
    var rootname = '车间';
    //定义树使用了命名空间
    treeMachine3 = new xyTree.DivTree(rootname);
    var node1;
    //定义节点也要使用命名空间，使用深度遍历方法逐个定义
    var dt = new Ajax.Web.DataTable();
    dt = Index.bindWorkPlace();
    if (dt.value != null && dt.value.Rows.length > 0) {
        for (var i = 0; i < dt.value.Rows.length; i++) {
            if (dt.value.Rows[i].DEPTNAME != null && dt.value.Rows[i].RECORDID.toString() != "") {
                node1 = new xyTree.Node(dt.value.Rows[i].DEPTNAME);
                node1.id = dt.value.Rows[i].RECORDID;
                treeMachine3.add(node1);
            }
        }
        dt = null;

    }

    var showTreeDiv = document.getElementById('showMachineInDept2');
    if (showTreeDiv.hasChildNodes()) {
        for (var n = 0; n < showTreeDiv.childNodes.length; n++)
            showTreeDiv.removeChild(showTreeDiv.childNodes[n]);
    }
    showTreeDiv.appendChild(treeMachine3.div);
    treeMachine3.init(null, null);

}

